//
//  MSAccuntView.m
//  觅尚
//
//  Created by No.8 on 2019/3/20.
//  Copyright © 2019 No.8. All rights reserved.
//

#import "MSAccuntView.h"

@implementation MSAccuntView

/** 登录标题*/
- (UILabel *)logintitle {
    if (!_logintitle) {
        _logintitle = [[UILabel alloc] init];
        _logintitle.frame = CGRectMake(150 * px, 300 * px, 150 * px, 70 * px);
        _logintitle.text  = @"登录";
        _logintitle.textColor = [UIColor whiteColor];
        _logintitle.font = [UIFont boldSystemFontOfSize:SYRealValue(38 / 2)];
        [self addSubview:_logintitle];
        
    }
    return _logintitle;
}

/** 手机号输入框*/
- (UITextField *)iphoneTextField{
    if (!_iphoneTextField) {
        _iphoneTextField = [[UITextField alloc] init];
        _iphoneTextField.frame = CGRectMake(self.logintitle.x, CGRectGetMaxY(_logintitle.frame) + 200 * px, ScreenWidth - _logintitle.x * 2, 150 * px);
        _iphoneTextField.placeholder = @"账号/手机号";
//        _iphoneTextField.text = @"17610697385";
        [_iphoneTextField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
        [_iphoneTextField setValue:[UIFont systemFontOfSize:SYRealValue(35 / 2)] forKeyPath:@"_placeholderLabel.font"];
        _iphoneTextField.keyboardType = UIKeyboardTypeNumberPad;
        _iphoneTextField.textColor = [UIColor whiteColor];
        [self addSubview:_iphoneTextField];
        
    }
    return _iphoneTextField;
    
}




/** 账号下划线*/
- (UIImageView *)iphonelineIMG {
    if (!_iphonelineIMG) {
        _iphonelineIMG = [[UIImageView alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_iphoneTextField.frame), ScreenWidth - _logintitle.x * 2, 1)];
        _iphonelineIMG.image = [UIImage imageNamed:@"line"];
        [self addSubview:_iphonelineIMG];
        
    }
    return _iphonelineIMG;
}

/** 验证码输入框*/
- (UITextField *)codeTextField{
    if (!_codeTextField) {
        _codeTextField = [[UITextField alloc] init];
        _codeTextField.frame = CGRectMake(self.logintitle.x, CGRectGetMaxY(_iphonelineIMG.frame) + 80 * px, _iphonelineIMG.width - 80 * px, _iphoneTextField.height);
        _codeTextField.placeholder = @"请输入密码";
//        _codeTextField.text = @"123456";
        [_codeTextField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
        [_codeTextField setValue:[UIFont systemFontOfSize:SYRealValue(35 / 2)] forKeyPath:@"_placeholderLabel.font"];
        _codeTextField.textColor = [UIColor whiteColor];
        _codeTextField.secureTextEntry = YES;
        [self addSubview:_codeTextField];
        
    }
    return _codeTextField;
    
}

/** 密码可见按钮*/
- (UIButton *)visibleButton{
    if (!_visibleButton) {
        _visibleButton = [[UIButton alloc] init];
        _visibleButton.frame = CGRectMake(CGRectGetMaxX(_codeTextField.frame), _codeTextField.y + 35 * px, 80 * px, 80 * px);
        [_visibleButton setImage:[UIImage imageNamed:@"不可见"] forState:UIControlStateNormal];
        [_visibleButton setImage:[UIImage imageNamed:@"可见"] forState:UIControlStateSelected];
        [self addSubview:_visibleButton];
        
    }
    return _visibleButton;
    
}



/** 密码下划线*/
- (UIImageView *)passworldlineIMG {
    if (!_passworldlineIMG) {
        _passworldlineIMG = [[UIImageView alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_codeTextField.frame), _iphonelineIMG.width, _iphonelineIMG.height)];
        _passworldlineIMG.image = [UIImage imageNamed:@"line"];
        [self addSubview:_passworldlineIMG];
        
    }
    return _passworldlineIMG;
}


/** 登录按钮*/
- (UIButton *)loginButton {
    if (!_loginButton) {
        _loginButton = [[UIButton alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_passworldlineIMG.frame) + 120 * px, _iphonelineIMG.width, 120 * px)];
        _loginButton.layer.cornerRadius = _loginButton.height * 0.5;
//        _loginButton.backgroundColor = [UIColor whiteColor];
        [_loginButton setTitle:@"登录" forState:UIControlStateNormal];
//        _loginButton.frame = CGRectMake(10, 50, 200, 44);
        
        CAGradientLayer *gradientLayer =  [CAGradientLayer layer];
        gradientLayer.frame = _loginButton.bounds;
        gradientLayer.cornerRadius = _loginButton.height * 0.5;
        gradientLayer.startPoint = CGPointMake(0, 0);
//        gradientLayer
        gradientLayer.endPoint = CGPointMake(1, 0);
        gradientLayer.locations = @[@(0.2),@(1.0)];//渐变点
        [gradientLayer setColors:@[(id)[WYCRGBColor(96, 59, 152) CGColor],(id)[WYCRGBColor(202, 72, 114) CGColor]]];//渐变数组
        [_loginButton.layer addSublayer:gradientLayer];
        _loginButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(36 / 2)];
        [self addSubview:_loginButton];
        
    }
    return _loginButton;
}

/** 手机快捷登录*/
- (UIButton *)choseButton {
    if (!_choseButton) {
        _choseButton = [[UIButton alloc] initWithFrame:CGRectMake(_logintitle.x + 10 * px, CGRectGetMaxY(_loginButton.frame) + 40 * px, _loginButton.width / 2.5, 100 * px)];
        //        _choseButton.backgroundColor = [UIColor whiteColor];
        [_choseButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_choseButton setTitle:@"手机快捷登录" forState:UIControlStateNormal];
        _choseButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        _choseButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(33 / 2)];
        [self addSubview:_choseButton];
    }
    return _choseButton;
}


/** 手机快捷登录*/
- (UIButton *)forgetButton {
    if (!_forgetButton) {
        _forgetButton = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth - _logintitle.x - (_loginButton.width / 3), _choseButton.y, _choseButton.width , _choseButton.height)];
        //        _choseButton.backgroundColor = [UIColor whiteColor];
        [_forgetButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_forgetButton setTitle:@"忘记密码?" forState:UIControlStateNormal];
        _forgetButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        _forgetButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(33 / 2)];
        [self addSubview:_forgetButton];
    }
    return _forgetButton;
}


/** 注册账号*/
- (UIButton *)registerButton {
    if (!_registerButton) {
        
        
        _registerButton = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth / 4, CGRectGetMaxY(_choseButton.frame) + 400 * px, ScreenWidth * 0.5, 100 * px)];
        _registerButton.layer.cornerRadius = _iphoneTextField.height * 0.5;
        //        _choseButton.backgroundColor = [UIColor whiteColor];
        [_registerButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_registerButton setTitle:@"没有账号？去注册" forState:UIControlStateNormal];
        _registerButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        _registerButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(35 / 2)];
        
        
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:_registerButton.titleLabel.text];
        [_registerButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(5,3)];
        _registerButton.titleLabel.attributedText = str;
        [_registerButton setAttributedTitle:str forState:UIControlStateNormal];
        [self addSubview:_registerButton];
    }
    return _registerButton;
}





- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        //        self.backgroundColor = [UIColor ];
        [self CreateSubView];
    }
    return self;
}
- (void)CreateSubView{
    
    self.backgroundColor = [UIColor whiteColor];
    
    //    [self logintitle];
    
}

@end
